package com.ruoyi.admin.service.impl;

import com.ruoyi.admin.mapper.EventApplyMapper;
import com.ruoyi.admin.mapper.EventDetailMapper;
import com.ruoyi.admin.service.IEventApplyService;
import com.ruoyi.common.core.domain.entity.EventApply;
import com.ruoyi.common.core.domain.entity.EventDetail;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 报名情况Service业务层处理
 * 
 * @author xukai
 * @date 2024-12-22
 */
@Service
public class EventApplyServiceImpl implements IEventApplyService 
{
    @Autowired
    private EventApplyMapper eventApplyMapper;

    @Autowired
    private EventDetailMapper eventDetailMapper;

    /**
     * 查询报名情况
     * 
     * @param id 报名情况主键
     * @return 报名情况
     */
    @Override
    public EventApply selectEventApplyById(Long id)
    {
        return eventApplyMapper.selectEventApplyById(id);
    }

    /**
     * 查询报名情况列表
     * 
     * @param eventApply 报名情况
     * @return 报名情况
     */
    @Override
    public List<EventApply> selectEventApplyList(EventApply eventApply)
    {
        List<EventApply> eventApplies = eventApplyMapper.selectEventApplyList(eventApply);
        List<EventApply> EventApplys = eventApplies.stream().map(e -> {
            EventApply EventApply = new EventApply();
            BeanUtils.copyProperties(e, EventApply);
            EventDetail eventDetail = eventDetailMapper.selectEventDetailById(e.getEventId());
            return EventApply;
        }).collect(Collectors.toList());
        return EventApplys;
    }

    /**
     * 新增报名情况
     * 
     * @param eventApply 报名情况
     * @return 结果
     */
    @Override
    public int insertEventApply(EventApply eventApply)
    {
        return eventApplyMapper.insertEventApply(eventApply);
    }

    /**
     * 修改报名情况
     * 
     * @param eventApply 报名情况
     * @return 结果
     */
    @Override
    public int updateEventApply(EventApply eventApply)
    {
        return eventApplyMapper.updateEventApply(eventApply);
    }

    /**
     * 批量删除报名情况
     * 
     * @param ids 需要删除的报名情况主键
     * @return 结果
     */
    @Override
    public int deleteEventApplyByIds(Long[] ids)
    {
        return eventApplyMapper.deleteEventApplyByIds(ids);
    }

    /**
     * 删除报名情况信息
     * 
     * @param id 报名情况主键
     * @return 结果
     */
    @Override
    public int deleteEventApplyById(Long id)
    {
        return eventApplyMapper.deleteEventApplyById(id);
    }
}
